import react from "react"

class Login extends react.Component {
    constructor() {
        super()
        this.state = { a: 1, is: false }
    }
    componentWillMount() {
        console.log("componentWillMount")
    }
    componentDidMount() {
        console.log("componentDidMount")
    }
    componentWillReceiveProps() {
        console.log("componentWillReceiveProps")
    }
    shouldComponentUpdate() {
        console.log("shouldComponentUpdate")
    }
    componentWillUpdate() {
        console.log("componentWillUpdate")
    }
    componentDidUpdate() {
        console.log("componentDidUpdate")
    }
    componentWillUnmount() {
        console.log("componentWillUnmount")
    }
    toregister() {
        this.props.history.push("./register")
        console.log(this)
    }
    // getSnapshotBeforeUpdate() {
    //     console.log("getSnapshotBeforeUpdate")
    // }
    jku() {
        this.setState({ is: !this.state.is })

        // this.setState(prevState => ({
        //     a: prevState.a++
        // }));
    }
    render() {
        let arr = [{ name: 1, age: 3 }, { name: 1, age: 3 }, { name: 1, age: 3 }];
        let divStyle = {
            color: 'red',
            display: "flex",

        };
        const block = (
            <div style={divStyle}>
                <div>sdfsdfad</div>
                <div>ffff</div>
            </div >

        )

        return (
            arr.map((item, index) => {
                return (
                    <div key={index}>
                        {block}
                        {this.state.is}
                        <h1 style={{ display: this.state.is ? "block" : "none" }}>{item.name}</h1>
                        <button onClick={this.jku.bind(this)}>点击</button>
                    </div>

                )
            })
        )
    }
}
export default Login